<?php
declare (strict_types = 1);
namespace app\admin\model\finance;

use app\common\model\BaseModel;
use think\facade\Request;
use app\user\logic\user\Account as User;

/**
 * 分成明细模型
 */
class SplitFlow extends BaseModel
{
    /**
     * 表名
     * @var string
     */
    protected $name = 'user_split_flow';

    /**
     * 时间显示格式
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i';

    protected $append = ['type_text'];
    
    protected function getTypeTextAttr($value='', $data)
    {
        $type_arr = [
            51 => '机构分成',
            52 => '讲师分成',
            53 => '挂载分成',
            54 => '分享者分成',
            55 => '一级分销分成',
            56 => '二级分销分成',
        ];
        return $type_arr[$data['type']];
    }

    public function userName()
    {
        return $this->belongsTo(User::class)->bind(['user_name']);
    }
}
